package com.stone.persistent.recyclerview.fragment;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;

import com.stone.persistent.recyclerview.R;
import com.stone.persistent.recyclerview.adapter.FeedsListAdapter;
import com.stone.persistent.recyclerview.extensions.ContextExtensions;
import com.stone.persistent.recyclerview.library.ChildRecyclerViews;
import com.stone.persistent.recyclerview.widget.GridItemDecoration;
import com.stone.persistent.recyclerview.widget.PersistentStaggeredGridLayoutManager;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;


public class FeedsFragment extends Fragment {
    private static final String TAG = "FeedsFragment";
    private ChildRecyclerViews childRecyclerView;

    @Nullable
    public View onCreateView(@NotNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_feeds_list, null);
        PersistentStaggeredGridLayoutManager layoutManager = new PersistentStaggeredGridLayoutManager(2);
        this.childRecyclerView = (ChildRecyclerViews) rootView;
        childRecyclerView.setLayoutManager(layoutManager);
        childRecyclerView.addItemDecoration(new GridItemDecoration(ContextExtensions.dp2px(getActivity(), 8f)));
        childRecyclerView.setAdapter(new FeedsListAdapter(getActivity()));
        Log.i(TAG, "onCreateView: ");
        return rootView;
    }

    @Override
    public void onCreate(@androidx.annotation.Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onResume() {
        super.onResume();
        Log.i(TAG, "onResume: ");
    }

    @Override
    public void onPause() {
        super.onPause();
        Log.i(TAG, "onPause: ");
    }

    @Override
    public void onStart() {
        super.onStart();
        Log.i(TAG, "onStart: ");
    }


}
